#include<bits/stdc++.h>
using namespace std;
typedef struct{
	int l,r,x;
}AD;
AD a[200011];
int k,m,n;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("copy.in","r",stdin);
	freopen("copy.out","w",stdout);
	cin >> k >> m;
	cin >> s;
	n = s.size();
	cin >> m;
	for(int i = 1;i <= m;i++)
		cin >> a[i].l >> a[i].r >> a[i].x;
	for(int t = 0;t < k;t++)
	{
		int p = t;
		for(int i = m;i;i--) if(a[i].x <= p)
		{
			if(p < a[i].x + a[i].r - a[i].l)
				p = a[i].l + (p - a[i].x);
			else
				p -= (a[i].r - a[i].l);
		}
		cout << s[p];
	}
	return 0;
}
